#defines
CPPFLAGS = -Wall -D_LINUX_ -fPIC
SHAREINCLUDE = ../
HEADERS = $(SHAREINCLUDE)XmlTool.h
XMLTOOL = ../XmlTool
LIBUTIL = ../../LibUtil/LibUtil
LIBS = XmlBindTest
CPP = g++
LDFLAGS = -L $(XMLTOOL) -L $(LIBUTIL) -lXmlTool -lLibUtil
VERSION ?= 1.0.0
DEBUG ?= FALSE

ifeq ($(DEBUG), TRUE)
CPPFLAGS += -g
else
CPPFLAGS += -O2
endif
	
#rules
libutil: 
	@cd $(LIBUTIL) && $(MAKE) all DEBUG=$(DEBUG)

xmltool:
	@cd $(XMLTOOL) && $(MAKE) all DEBUG=$(DEBUG)

$(LIBS) : $(HEADER)
	$(CPP) $(LIBS).cpp -o $(LIBS) $(LDFLAGS) $^

.PHONY : clean
.DEFAULT : all

all : libutil xmltool $(LIBS)

install :
	@cp $(LIBUTIL)/libLibUtil.so /usr/lib/
	@cp $(XMLTOOL)/libXmlTool.so /usr/lib/

clean:
	@cd $(XMLTOOL) && $(MAKE) clean
	@cd $(LIBUTIL) && $(MAKE) clean
	@rm -f *.o *.so.* *.so $(LIBS)


